#!/bin/bash

latest=2022.2.2
latestcommit=73b8028be184cabf15b77da1d456b8da9b030a68

if [ -z "$1" ]
then
  echo -e "\033[31m未指定版本\033[0m"
  echo -e "\033[35m开始打包最新版本 >>> $latest\033[0m"
  git reset --hard $latestcommit
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
elif [ "$1" == "$latest" ]
then
  echo -e "\033[35m开始打包指定版本 >>> $latest\033[0m"
  git reset --hard $latestcommit
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
elif [ "$1" == "2022.2.2" ]
then
  echo -e "\033[35m开始打包指定版本 >>> 2022.2.2\033[0m"
  git reset --hard 73b8028be184cabf15b77da1d456b8da9b030a68
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
elif [ "$1" == "2022.1.1" ]
then
  echo -e "\033[35m开始打包指定版本 >>> 2022.1.1\033[0m"
  git reset --hard 6e02b4cac1fee0464739b6c722804b9450da8710
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
elif [ "$1" == "2021.0.1" ]
then
  echo -e "\033[35m开始打包指定版本 >>> 2021.0.1\033[0m"
  git reset --hard 4028311db3856a9e2c3ff0aceb708fa54d215bce
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
else
  echo -e "\033[31m无指定版本\033[0m"
  echo -e "\033[35m开始打包最新版本 >>> $latest\033[0m"
  git reset --hard $latestcommit
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
fi
